import { reactive } from "vue";
import { getAllCompanyApi, getUserByPositionApi } from "@/api/managementCenter/departmentPersonnel";
import { getAllCustomerApi } from "@/api/common";
export const searchItemList: Array<SuperSearch.SearchItem> = [
  {
    type: "input",
    label: "放货单号",
    keyName: "applyNoList",
    placeholder: "支持批量(空格/逗号隔开)"
  },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "客户",
    keyName: "customerIdList",
    optionsRequest: getAllCustomerApi,
    optReqParams: { isFilterChild: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    optConfig: {
      label: "shortName",
      value: "id"
    },
    attrs: {
      mode: "multiple"
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "经营单位",
    keyName: "companyIdList",
    optionsRequest: getAllCompanyApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    attrs: {
      mode: "multiple"
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "业务员",
    keyName: "bizIdList",
    optionsRequest: getUserByPositionApi,
    optReqParams: { position: "4", status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    optConfig: {
      label: "username",
      value: "id"
    },
    attrs: {
      mode: "multiple"
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "跟单员",
    keyName: "followIdList",
    optionsRequest: getUserByPositionApi,
    optReqParams: { position: "5", status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    optConfig: {
      label: "username",
      value: "id"
    },
    attrs: {
      mode: "multiple"
    },
    options: []
  })
];

export const tableColumnMap: Base.GeneraDataType<Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem>> = {
  1: [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "applyNo",
      title: "放货单号",
      minWidth: "160"
    },
    {
      field: "customerName",
      title: "客户",
      minWidth: "120"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "90"
    },
    {
      field: "applyType",
      title: "申请类型",
      minWidth: "100",
      renderSlot: "applyType"
    },
    {
      field: "applyRemark",
      title: "申请备注",
      minWidth: "90"
    },
    {
      field: "overdueBillNo",
      title: "逾期账单",
      minWidth: "140"
    },
    {
      field: "overdueAmount",
      title: "逾期金额(CNY)",
      minWidth: "90"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "80"
    },
    {
      field: "followName",
      title: "跟单员",
      minWidth: "120"
    },
    {
      field: "createName",
      title: "申请人",
      minWidth: "80"
    },
    {
      field: "createTime",
      title: "申请时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "bizFileDetailReqDtoList",
      title: "附件",
      minWidth: "135",
      renderSlot: "bizFileDetailReqDtoList",
      fixed: "right"
    }
  ],
  2: [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "applyNo",
      title: "放货单号",
      minWidth: "160"
    },
    {
      field: "customerName",
      title: "客户",
      minWidth: "120"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "90"
    },
    {
      field: "applyType",
      title: "申请类型",
      minWidth: "100",
      renderSlot: "applyType"
    },
    {
      field: "applyRemark",
      title: "申请备注",
      minWidth: "120"
    },
    {
      field: "overdueBillNo",
      title: "逾期账单",
      minWidth: "140"
    },
    {
      field: "overdueAmount",
      title: "逾期金额(CNY)",
      minWidth: "90"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "80"
    },
    {
      field: "followName",
      title: "跟单员",
      minWidth: "120"
    },
    {
      field: "createName",
      title: "申请人",
      minWidth: "80"
    },
    {
      field: "createTime",
      title: "申请时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "applyName",
      title: "审批人",
      minWidth: "80"
    },
    {
      field: "applyTime",
      title: "审批时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "bizFileDetailReqDtoList",
      title: "附件",
      minWidth: "135",
      renderSlot: "bizFileDetailReqDtoList",
      fixed: "right"
    }
  ],
  3: [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "applyNo",
      title: "放货单号",
      minWidth: "160"
    },
    {
      field: "customerName",
      title: "客户",
      minWidth: "120"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "90"
    },
    {
      field: "applyType",
      title: "申请类型",
      minWidth: "100",
      renderSlot: "applyType"
    },
    {
      field: "applyRemark",
      title: "申请备注",
      minWidth: "90"
    },
    {
      field: "overdueBillNo",
      title: "逾期账单",
      minWidth: "140"
    },
    {
      field: "overdueAmount",
      title: "逾期金额(CNY)",
      minWidth: "90"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "80"
    },
    {
      field: "followName",
      title: "跟单员",
      minWidth: "120"
    },
    {
      field: "createName",
      title: "申请人",
      minWidth: "80"
    },
    {
      field: "createTime",
      title: "申请时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "applyName",
      title: "审批人",
      minWidth: "80"
    },
    {
      field: "applyTime",
      title: "审批时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "applyResult",
      title: "驳回原因",
      minWidth: "120"
    },
    {
      field: "bizFileDetailReqDtoList",
      title: "附件",
      minWidth: "135",
      renderSlot: "bizFileDetailReqDtoList",
      fixed: "right"
    }
  ]
};
